package com.codegenerate.demo.entity;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.codegenerate.demo.config.R;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

public class SysDictionaryDto implements Serializable {
    private long id;

    int pageNum;
    int pageSize;
    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public R validateUpdate(){
        if(this.getId()<0){
            return R.failed("id 不能为空");
        }
        return R.ok(null);
    }










    /**
     * 名称
     */
    private String name;




    /**
     * 标识码
     */
    private String code;




    /**
     * 所属分类
     */
    private int classId;




    /**
     * 所有分类路径
     */
    private String classIdPath;




    /**
     * 状态 1 使用中  5停用
     */
    private int state;




    /**
     * 排序号
     */
    private int orderNum;




    /**
     * 备注
     */
    private String remarks;




    /**
     * 信息级别 0系统级 10租户级
     */
    private int infoLevel;




    /**
     * 租户类型 1应用管理者2应用消息者
     */
    private int tenantType;




    /**
     * 租户ID
     */
    private int tenantId;




    /**
     * 有效状态[数据字典=del_state] 1有效  5删除
     */
    private int delState;




    /**
     * 添加人
     */
    private String addUser;




    /**
     * 添加人ID
     */
    private int addUserId;




    /**
     * 添加时间
     */
    private LocalDateTime addTime;




    /**
     * 最近更新人
     */
    private String editUser;




    /**
     * 最近更新人ID
     */
    private int editUserId;




    /**
     * 最近更新时间
     */
    private LocalDateTime lastEditTime;




    /**
     * 服务器编号ID
     */
    private int serverNumber;









    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }

    public int getClassId() {
        return classId;
    }
    public void setClassId(int classId) {
        this.classId = classId;
    }

    public String getClassIdPath() {
        return classIdPath;
    }
    public void setClassIdPath(String classIdPath) {
        this.classIdPath = classIdPath;
    }

    public int getState() {
        return state;
    }
    public void setState(int state) {
        this.state = state;
    }

    public int getOrderNum() {
        return orderNum;
    }
    public void setOrderNum(int orderNum) {
        this.orderNum = orderNum;
    }

    public String getRemarks() {
        return remarks;
    }
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public int getInfoLevel() {
        return infoLevel;
    }
    public void setInfoLevel(int infoLevel) {
        this.infoLevel = infoLevel;
    }

    public int getTenantType() {
        return tenantType;
    }
    public void setTenantType(int tenantType) {
        this.tenantType = tenantType;
    }

    public int getTenantId() {
        return tenantId;
    }
    public void setTenantId(int tenantId) {
        this.tenantId = tenantId;
    }

    public int getDelState() {
        return delState;
    }
    public void setDelState(int delState) {
        this.delState = delState;
    }

    public String getAddUser() {
        return addUser;
    }
    public void setAddUser(String addUser) {
        this.addUser = addUser;
    }

    public int getAddUserId() {
        return addUserId;
    }
    public void setAddUserId(int addUserId) {
        this.addUserId = addUserId;
    }

    public LocalDateTime getAddTime() {
        return addTime;
    }
    public void setAddTime(LocalDateTime addTime) {
        this.addTime = addTime;
    }

    public String getEditUser() {
        return editUser;
    }
    public void setEditUser(String editUser) {
        this.editUser = editUser;
    }

    public int getEditUserId() {
        return editUserId;
    }
    public void setEditUserId(int editUserId) {
        this.editUserId = editUserId;
    }

    public LocalDateTime getLastEditTime() {
        return lastEditTime;
    }
    public void setLastEditTime(LocalDateTime lastEditTime) {
        this.lastEditTime = lastEditTime;
    }

    public int getServerNumber() {
        return serverNumber;
    }
    public void setServerNumber(int serverNumber) {
        this.serverNumber = serverNumber;
    }




    /**
     * build
     */
    public static SysDictionaryDto build(){
        SysDictionaryDto temp = new SysDictionaryDto();



        temp.setId(0);

        temp.setName("");

        temp.setCode("");

        temp.setClassId(0);

        temp.setClassIdPath("");

        temp.setState(0);

        temp.setOrderNum(0);

        temp.setRemarks("");

        temp.setInfoLevel(0);

        temp.setTenantType(0);

        temp.setTenantId(0);

        temp.setDelState(1);

        temp.setAddUser("");

        temp.setAddUserId(0);

        temp.setAddTime(LocalDateTime.now());

        temp.setEditUser("");

        temp.setEditUserId(0);

        temp.setLastEditTime(LocalDateTime.now());

        temp.setServerNumber(0);


        return temp;
    }

    /**
     * setDefaultValue
     */
    public void  setDefaultValue(SysDictionaryDto temp){

        if(this.id<=0){
            temp.setId(0);
        }

        if(StringUtils.isEmpty(this.name)){
            temp.setName("");
        }

        if(StringUtils.isEmpty(this.code)){
            temp.setCode("");
        }

        if(this.classId<=0){
            temp.setClassId(0);
        }

        if(StringUtils.isEmpty(this.classIdPath)){
            temp.setClassIdPath("");
        }

        if(this.state<=0){
            temp.setState(0);
        }

        if(this.orderNum<=0){
            temp.setOrderNum(0);
        }

        if(StringUtils.isEmpty(this.remarks)){
            temp.setRemarks("");
        }

        if(this.infoLevel<=0){
            temp.setInfoLevel(0);
        }

        if(this.tenantType<=0){
            temp.setTenantType(0);
        }

        if(this.tenantId<=0){
            temp.setTenantId(0);
        }

        if(this.delState<=0){
            temp.setDelState(1);
        }

        if(StringUtils.isEmpty(this.addUser)){
            temp.setAddUser("");
        }

        if(this.addUserId<=0){
            temp.setAddUserId(0);
        }

        if(null==this.addTime){
            temp.setAddTime(LocalDateTime.now());
        }

        if(StringUtils.isEmpty(this.editUser)){
            temp.setEditUser("");
        }

        if(this.editUserId<=0){
            temp.setEditUserId(0);
        }

        if(null==this.lastEditTime){
            temp.setLastEditTime(LocalDateTime.now());
        }

        if(this.serverNumber<=0){
            temp.setServerNumber(0);
        }

    }



    /**
     * dto2entity
     */
    public SysDictionary  dto2entity(){
        var entity=SysDictionary.build();

        if(this.id>0){
            entity.setId(this.getId());
        }

        if(!StringUtils.isEmpty(this.name)){
            entity.setName(this.getName());
        }

        if(!StringUtils.isEmpty(this.code)){
            entity.setCode(this.getCode());
        }

        if(this.classId>0){
            entity.setClassId(this.getClassId());
        }

        if(!StringUtils.isEmpty(this.classIdPath)){
            entity.setClassIdPath(this.getClassIdPath());
        }

        if(this.state>0){
            entity.setState(this.getState());
        }

        if(this.orderNum>0){
            entity.setOrderNum(this.getOrderNum());
        }

        if(!StringUtils.isEmpty(this.remarks)){
            entity.setRemarks(this.getRemarks());
        }

        if(this.infoLevel>0){
            entity.setInfoLevel(this.getInfoLevel());
        }

        if(this.tenantType>0){
            entity.setTenantType(this.getTenantType());
        }

        if(this.tenantId>0){
            entity.setTenantId(this.getTenantId());
        }

        if(this.delState>0){
            entity.setDelState(this.getDelState());
        }

        if(!StringUtils.isEmpty(this.addUser)){
            entity.setAddUser(this.getAddUser());
        }

        if(this.addUserId>0){
            entity.setAddUserId(this.getAddUserId());
        }

        if(null!=this.addTime){
            entity.setAddTime(this.getAddTime());
        }

        if(!StringUtils.isEmpty(this.editUser)){
            entity.setEditUser(this.getEditUser());
        }

        if(this.editUserId>0){
            entity.setEditUserId(this.getEditUserId());
        }

        if(null!=this.lastEditTime){
            entity.setLastEditTime(this.getLastEditTime());
        }

        if(this.serverNumber>0){
            entity.setServerNumber(this.getServerNumber());
        }

        return entity;
    }



    public Page<SysDictionary> buildPage(){
        Page<SysDictionary> tempage = new Page<SysDictionary>();
        tempage.setCurrent(this.getPageNum()<=0?0:this.getPageNum());
        tempage.setSize(this.getPageSize()<=0?10:this.getPageSize());
        return tempage;
    }


}